package com.zrq.secondkill.dao;

import com.zrq.secondkill.dataobject.ItemStockDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

@Component
public interface ItemStockDOMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(ItemStockDO record);

    int insertSelective(ItemStockDO record);

    ItemStockDO selectByPrimaryKey(Integer id);

    ItemStockDO selectByItemId(Integer itemId);

    int updateByPrimaryKeySelective(ItemStockDO record);

    int updateByPrimaryKey(ItemStockDO record);

    int updateByItemId(@Param("itemID")Integer itemId,@Param("amount") Integer amount);

    /**
     * 如果库存足够,则扣减amount
     *
     * @param itemId
     * @param amount
     * @return 修改的行数
     */
    int decreaseStockIfEnough(@Param("itemID")Integer itemId, @Param("amount") Integer amount);

}